//
//  WHStatus.swift
//  WHSinaWeiBo
//
//  Created by 王寒 on 16/4/11.
//  Copyright © 2016年 wanghan. All rights reserved.
//

import UIKit

class WHStatus: NSObject {

    //唯一ID
    var id: Int64 = 0
    //微博创建时时间
    var created_at: String?
    //微博来源
    var source: String?
    //微博正文
    var text: String?
    //用户属性
    var user: WHUser?
    //转发的个数
    var reposts_count: Int = 0
    //评论的个数
    var comments_count: Int = 0
    //赞的个数
    var attitudes_count: Int = 0
    
    //图片数组 
    var pic_urls: [WHStatusPicture]?
    
    //转发微博
    var retweeted_status: WHStatus?
    //字典转模型
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
        
            user = WHUser(dict: value as! [String : AnyObject])
            
            return
        }
        
        if key == "retweeted_status"{
            //字典转模型
            retweeted_status = WHStatus(dict: value as! [String:AnyObject])
            return
        }
        
        if key == "pic_urls"{
            var tempArr = [WHStatusPicture]()
            for d in value as! [[String:String]]{
                let p = WHStatusPicture(dict: d)
                tempArr.append(p)
            }
            pic_urls = tempArr
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
}
